<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('菜单权限列表')" />
</head>
<style type="text/css">
    .select-table table {
        table-layout:auto;
    }

    .select-table .table td {
        /* 超出部分隐藏 */
        overflow:hidden;
        /* 超出部分显示省略号 */
        text-overflow:ellipsis;
        /*规定段落中的文本不进行换行 */
        white-space:nowrap;
        /* 配合宽度来使用 */
        height:40px;
    }
</style>
<body class="gray-bg">
<input th:value="${@permission.getPrincipalProperty('userName')}" hidden="hidden">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>商品条码：</p>
                                <input type="text" name="sptm"/>
                            </li>
                            <li>
                                <p>通用名称：</p>
                                <input type="text" name="spmch"/>
                            </li>
                            <li>
                                <p>助记码：</p>
                                <input type="text" name="zjm"/>
                            </li>
                            <li>
                                <p>产地：</p>
                                <input type="text" name="shpchd"/>
                            </li>
                            <li>
                                <p>商品规格：</p>
                                <input type="text" name="shpgg"/>
                            </li>
                            <li>
                                <p>别名：</p>
                                <input type="text" name="tongym"/>
                            </li>
                            <li>
                                <p>生产厂家：</p>
                                <input type="text" name="shengccj"/>
                            </li>
                            <li>
                                <p>批准文号：</p>
                                <input type="text" name="pizhwh"/>
                            </li>
                            <li>
                                <p>剂型：</p>
                                <input type="text" name="jixing"/>
                            </li>
                            <li>
                                <p>类别：</p>
                                <input type="text" name="leibie"/>
                            </li>
                            <li>
                                <p>档案编号：</p>
                                <input type="text" name="dabh"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:spkfk:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:spkfk:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:spkfk:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:user:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:spkfk:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped" >
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:spkfk:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:spkfk:remove')}]];
        var prefix = ctx + "system/spkfk";

        // function rowStyle(row, index) {
        //     var style = { css: { 'color': '#38b48b','border':'10px'} };
        //     return style;
        // }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                exportUrl: prefix + "/export",
                modalName: "商品信息",
                showFooter: true,
                //rowStyle: rowStyle,
                columns: [{
                    checkbox: true,
                    footerFormatter:function (value) {
                        var sumBalance = 0;
                        for (var i in value) {
                            sumBalance += parseFloat(value[i].youxq);
                        }
                        return "总金额：" + sumBalance + "   所有行汇总：" +[[${huizong}]];
                    }
                },
                {
                    field : 'spid', 
                    title : '商品内码',
                },
                {
                    field : 'spbh', 
                    title : '商品编号'
                },
                {
                    field : 'sptm', 
                    title : '商品条码'
                },
                {
                    field : 'spmch', 
                    title : '通用名称',
                    sortable: true,
                },
                {
                    field : 'dw', 
                    title : '包装单位'
                },
                {
                    field : 'shpchd', 
                    title : '产地'
                },
                {
                    field : 'shpgg', 
                    title : '商品规格'
                },
                {
                    field : 'tongym', 
                    title : '别名'
                },
                {
                    field : 'shengccj', 
                    title : '生产厂家'
                },
                {
                    field : 'pizhwh', 
                    title : '批准文号'
                },
                {
                    field : 'jixing', 
                    title : '剂型'
                },
                {
                    field : 'youxq', 
                    title : '有效期',
                    sortable: true,
                },
                {
                    field : 'leibie', 
                    title : '类别'
                },
                {
                    field : 'pizhwhyxq', 
                    title : '批准文号有效期'
                },
                {
                    field : 'dabh', 
                    title : '档案编号'
                },
                {
                    field : 'jxq', 
                    title : '是否近效期'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.spid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.spid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的商品信息
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>